package com.ll3d.security;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * @Author:linchong
 * @CreateTime:2020-07-15 19:25
 * @Description:
 */
@Data
public class AccessToken {

	private String access_token;

	private String refresh_token;

	private String token_type;

	//过期时间 秒
	private Long expires_in;

	private String scope;

	//过期时间
	private LocalDateTime expireTime;

	//设置token的失效日期
	public AccessToken init(){
		//expires_in -3 秒，在token失效之前就失效
		expireTime = LocalDateTime.now().plusSeconds(expires_in -3);
		return this;
	}
	//令牌是否过期
	public boolean isExpired(){
		return expireTime.isBefore(LocalDateTime.now());
	}
}
